package com.mineoj.controller;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mineoj.annotation.AuthCheck;
import com.mineoj.common.BaseResponse;
import com.mineoj.common.DeleteRequest;
import com.mineoj.common.ErrorCode;
import com.mineoj.common.ResultUtils;
import com.mineoj.constant.UserConstant;
import com.mineoj.exception.BusinessException;
import com.mineoj.exception.ThrowUtils;
import com.mineoj.model.dto.competitionranking.CompetitionRankingQueryRequest;
import com.mineoj.model.entity.CompetitionRanking;
import com.mineoj.model.entity.CompetitionRanking;
import com.mineoj.model.entity.User;
import com.mineoj.service.CompetitionRankingService;
import com.mineoj.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 帖子接口
 *
 
 */
@RestController
@RequestMapping("/competition_ranking")
@Slf4j
public class CompetitionRankingController {

    @Resource
    private CompetitionRankingService competitionRankingService;

    @Resource
    private UserService userService;


    /**
     * 分页获取列表
     *
     * @param competitionRankingQueryRequest
     * @return
     */
    @PostMapping("/list/page")
    public BaseResponse<Page<CompetitionRanking>> listCompetitionRankingByPage(@RequestBody CompetitionRankingQueryRequest competitionRankingQueryRequest) {
        long current = competitionRankingQueryRequest.getCurrent();
        long size = competitionRankingQueryRequest.getPageSize();
        Page<CompetitionRanking> competitionRankingPage = competitionRankingService.page(new Page<>(current, size),
                competitionRankingService.getQueryWrapper(competitionRankingQueryRequest));
        return ResultUtils.success(competitionRankingPage);
    }

 

}
